﻿@if (Announcements != null)
{
    <div class="dropdown">
        <button class="btn btn-secondary dropdown-toggle" type="button" id="announcementDropdown" data-bs-toggle="dropdown" aria-expanded="false">
            公告栏消息 <span class="badge bg-danger">@UnreadCount</span>
        </button>
        <ul class="dropdown-menu" aria-labelledby="announcementDropdown">

            @foreach (var announcement in Announcements)
            {
                var isRead = IsAnnouncementRead(announcement.Id);
                <li>
                    <a class="dropdown-item @(isRead ? "" : "bg-warning text-danger")" @onclick="@(() => MarkAsReadAsync(announcement.Id))">
                        <div>
                            <span>@announcement.Title</span>
                        </div>
                        <div>@announcement.Content</div>
                        <div><small class="text-muted">@announcement.PublishTime.ToString("yyyy-MM-dd HH:mm")</small></div>
                    </a>

                </li>

            }

        </ul>
    </div>

}
